//
//  ZWVisitorViewController.swift
//  ZWWeibo
//
//  Created by flyiron on 16/4/16.
//  Copyright © 2016年 flyiron. All rights reserved.
//

import UIKit

class ZWVisitorViewController: UITableViewController,ZWVisitorViewDelegate {
    
    var isLogin: Bool = ZWUserInfoViewModel.sharedViewModel.isLogin
    
    override func loadView() {
        if isLogin {
            super.loadView()
        }else{
            loadVisitorView()
        }
    }
    
    
    func loadVisitorView() {
        view = visitorView
        
        let registerBTN = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ZWVisitorViewDelegate.clickRegister))
        let loginBTN = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ZWVisitorViewDelegate.clickLogin))
        navigationItem.leftBarButtonItem = registerBTN
        navigationItem.rightBarButtonItem = loginBTN
    }
    
    func clickLogin() {
//        print("登录按钮被点击了delegate")
        let vc = ZWOAuthViewController()
        presentViewController(UINavigationController(rootViewController: vc), animated: true, completion: nil)
    }
    
    func clickRegister() {
        print("注册按钮被点击了delegate")

    }
    
    
   
    lazy var visitorView: ZWVisitorView = {
        let visitor = ZWVisitorView()
        visitor.delegate = self
        return visitor
    }()
}
